type
	queue=record
		a:array of int64;
		h,t:longint;
	end;

procedure new(var q:queue);
begin
setlength(q.a,0);
q.h:=0;
q.t:=-1;
end;
	
procedure push(var q:queue; v:int64);
begin
setlength(q.a,length(q.a)+1);
inc(q.t);
q.a[q.t]:=v;
end;

function pop(var q:queue):int64;
begin
if length(q.a)=0 then begin
	result:=-maxlongint;
	exit;
end;
result:=q.a[q.h];
inc(q.h);
end;

function front(q:queue):int64;
begin
if length(q.a)=0 then begin
	result:=-maxlongint;
	exit;
end;
result:=q.a[q.h];
end;